Tour 1 - Temperature

In this Quick Tour we will recreate the Temperature example. It demonstrates AppMaker's programming model, separating user interface (UI) from data "engine", and connecting UI elements to data elements.

Creating a File
Defining Data
Creating the User Interface
Adding Your Code
Generating Code
Compiling and Linking
Running the Built Application

Creating a File


Defining Data


Creating the User Interface

Run the pre-built Temperature68K example (it's in the AppMaker 2: Examples folder) as a guide for creating the main window.

Adding Your Code

When creating the user interface, we connected the CentEdit field and the CentSlider to the Centigrade data member. Changing either UI item will automatically change the data member and will change the other UI item. I.e. typing a value into the edit field will change the slider, and changing the slider will change the value of the edit field. Similarly, the FahrEdit field and the FahrBar are connected to the Fahrenheit data member. Typing into the edit field will change the thermometer.

What's missing is a connection between the Centigrade items and the Fahrenheit items. In this section we will add code to convert between Centigrade and Fahrenheit and to change all of the UI items whenever any one of them is changed.

Here is the contest we announced earlier. The two formulas above have a very small bug. To the first reader who offers a simple correction we will extend your AppMaker subscription. To enter the contest, just send e-mail to BowersDev@aol.com.

These few lines of code cause both the Centigrade value and the Fahrenheit value to be changed whenever either one is changed. When a UI item changes the Centigrade value, then the UI items connected to the Fahrenheit data member will also change. Similarly, changing a Fahrenheit UI item will change the two Centigrade UI items.


Generating Code


Compiling and Linking


Running the Built Application

Type values into either the Centigrade or Fahrenheit fields, then press Enter or the Tab key. Drag the Centigrade slider's indicator. Changing any of the UI items causes all four items to display the new value.

Temperature is a working and useful application that was generated by AppMaker with only four lines of hand-written code.

As a general rule, your code will be part of the "engine" rather than part of the UI. Your code will respond to changes in a data element by computing other data and then signaling that the data has changed. UI code responds to changes in data by displaying new data.

The purpose of a UI is to display data and to modify data. AppMaker generates code that gets data values and displays them in UI elements, then responds to user changes by modifying data elements accordingly. Multiple UI elements, possibly in multiple windows or dialogs, can change the same data element. The generated code listens for changes to the data, then UI elements Get the new data values and display them.


Continue to Tour 2